package com.xipu.yygh.task.scheduled;

import com.xipu.yygh.rabbit.constant.MqConst;
import com.xipu.yygh.rabbit.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * description: 执行定时任务
 * @author: gql
 * @date: 2022/05
 */
@EnableScheduling
@Component
public class SchedulingTask {
    /**
     * RabbitMQ发消息
     */
    @Autowired
    private RabbitService rabbitService;

    /**
     * 就医提醒定时任务:每天08:00执行一次.
     */
    @Scheduled(cron = "0 0 8 * * ?")
    public void patientTips() {
        System.out.println(LocalDateTime.now());
        this.rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK, MqConst.ROUTING_TASK_8, "");
    }
}
